package com.fywsy.fyweb.strategy;

import com.fywsy.fyweb.entity.SendItem;
import com.fywsy.fyweb.utils.RestTemplateUtil;
import org.springframework.stereotype.Component;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;

/**
 * 游戏后台实现类
 * 注解gameId对应数据库游戏id
 * 注解GongnengMethod对应数据库功能id
 */
@Component
@GameId(5)
public class JiangshiGameStrategy extends BaseGameStrategy {
    public static final String MAIL = "http://114.66.45.140:30381/ht303/vip/api.php";

    //usr=18655556666&bao=500006&num=2&item=91037&items=0&nums=&quid=1&gnxz=2
    @GongnengMethod(501)
    public String mail(SendItem item) {
        MultiValueMap<String,String> params = new LinkedMultiValueMap<>();
        params.add("usr",item.uid);
        params.add("item",item.itemId);
        params.add("num",item.number);
        params.add("gnxz","2");
        params.add("quid","1");

        params.add("bao","0");
        params.add("items","0");
        params.add("nums","0");

        return RestTemplateUtil.sendPostForm(MAIL, params);
    }

    /**
     * 增加等级,跳关,增加货币等
     * @param item
     * @return
     */
    //usr=18655556666&bao=500102&num=2&item=91037&items=1&nums=666&quid=1&gnxz=3
    @GongnengMethod(502)
    public String add(SendItem item) {
        MultiValueMap<String,String> params = new LinkedMultiValueMap<>();
        params.add("usr",item.uid);
        params.add("items",item.itemId);
        params.add("nums",item.number);
        params.add("gnxz","3");
        params.add("quid","1");

        params.add("bao","0");
        params.add("item","0");
        params.add("num","0");

        return RestTemplateUtil.sendPostForm(MAIL, params);
    }

    @GongnengMethod(4)
    public String cleat(SendItem item) {
        System.out.println("清除成功");
        return "清除成功";
    }


    public static void main(String[] args) {
        JiangshiGameStrategy jiangshiGameStrategy = new JiangshiGameStrategy();
        SendItem item = new SendItem();
        item.uid = "18655556666";
        item.itemId = "91034";
        item.number = "2";
        String mail = jiangshiGameStrategy.mail(item);
        System.out.println(mail);
    }
}

